home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / tcclib.zip / TCCLIB.DOC < prev    next >
Text File  |  1989-02-13  |  38KB  |  997 lines

  1. -------------------------------------------------------------------------
  2. Accept
  3. -------------------------------------------------------------------------
  4. void Accept( int x, int y, char *Prompt, char *Buffer, int Length );
  5.  
  6. Parameters:
  7.     x,y     column, row where the prompt will be printed
  8.     Prompt  the prompt
  9.     Buffer  the address of the buffer where the response is stored
  10.     Length  the maximum allowed length of the response
  11.  
  12. -------------------------------------------------------------------------
  13. AllBlanks
  14. -------------------------------------------------------------------------
  15. int AllBlanks( register char *cp );
  16.  
  17. Returns 1 if the string is null or all spaces.  If the string
  18. contains any non-space characters, it returns 0.
  19.  
  20. -------------------------------------------------------------------------
  21. AtSay
  22. -------------------------------------------------------------------------
  23. void AtSay( int col, int row, register char *string );
  24.  
  25. Writes the string at the given position on the screen, using the
  26. global variable "attrib" for the screen attribute.
  27.  
  28. -------------------------------------------------------------------------
  29. AtSayA
  30. -------------------------------------------------------------------------
  31. void AtSayA( int col, int row, unsigned char attrib, register char *cp );
  32.  
  33. Writes the string at the given position on the screen, using the
  34. paramter "attrib" for the screen attribute.
  35.  
  36. -------------------------------------------------------------------------
  37. AtSayF
  38. -------------------------------------------------------------------------
  39. void AtSayF( int col, int row, char *fmt, ... );
  40.  
  41. Writes the string at the given position on the screen, using the
  42. global variable "attrib" for the screen attribute.  This function
  43. allows the "printf" convention of multiple parameters.
  44.  
  45. Example: AtSayF( 5, 10, "%d %s %d", 15, "Hello World", 73 )
  46.  
  47. -------------------------------------------------------------------------
  48. AtSayFA
  49. -------------------------------------------------------------------------
  50. void AtSayFA( int col, int row, unsigned char attrib, char *fmt, ... );
  51.  
  52. Writes the string at the given position on the screen, using the
  53. paramter "attrib" for the screen attribute.  This function
  54. allows the "printf" convention of multiple parameters.
  55.  
  56. -------------------------------------------------------------------------
  57. Beep
  58. -------------------------------------------------------------------------
  59. void Beep();
  60.  
  61. Beep sounds the seaker.
  62.  
  63. -------------------------------------------------------------------------
  64. Bit
  65. -------------------------------------------------------------------------
  66. unsigned Bit( int x );
  67.  
  68. Returns the value of the xth bit.  X is zero-relative.
  69. Example: Bit(0) = 1, Bit(7) = 256
  70.  
  71. -------------------------------------------------------------------------
  72. BlockErase
  73. -------------------------------------------------------------------------
  74. void BlockErase( int x, int y, int xx, int yy );
  75.  
  76. Erases the block (window) on the screen with the top left corner
  77. denoted by x,y and the bottom right corner denoted by xx,yy.  The
  78. global variable "attrib" is used to determine what attribute will
  79. be used for the area that is erased.
  80.  
  81. -------------------------------------------------------------------------
  82. CapsLock
  83. -------------------------------------------------------------------------
  84. void CapsLock( int flag );
  85.  
  86. If "flag" is non-zero, the caps lock will be turned on.  If "flag"
  87. is zero, the caps lock will be turned off.
  88.  
  89. -------------------------------------------------------------------------
  90. Center
  91. -------------------------------------------------------------------------
  92. void Center( int y, char *s );
  93.  
  94. Centers the string "s" on the row "y", using the global variable
  95. "attrib" for screen attributes.
  96.  
  97. -------------------------------------------------------------------------
  98. CenterA
  99. -------------------------------------------------------------------------
  100. void CenterA( int y, unsigned char attrib, char *s );
  101.  
  102. Centers the string "s" on the row "y", using the parameter
  103. "attrib" for screen attributes.
  104.  
  105. -------------------------------------------------------------------------
  106. CenterF
  107. -------------------------------------------------------------------------
  108. void CenterF( int y, char *fmt, ... );
  109.  
  110. Centers the given string on the row "y", using the parameter
  111. "attrib" for screen attributes.  Allows multiple parameters like
  112. "printf".
  113.  
  114. Example: CenterF( 10, "%s %s %s", "This", "is", "centered" );
  115.  
  116. -------------------------------------------------------------------------
  117. CenterFA
  118. -------------------------------------------------------------------------
  119. void CenterFA( int y, unsigned char attrib, char *fmt, ... );
  120.  
  121. Centers the given string on the row "y", using the parameter
  122. "attrib" for screen attributes.  Allows multiple parameters like
  123. "printf".
  124.  
  125. -------------------------------------------------------------------------
  126. ChangeBlock
  127. -------------------------------------------------------------------------
  128. void ChangeBlock( int x, int y, int xx, int yy, char attrib );
  129.  
  130. ChangeBlock changes the attributes of a block on the screen.  The
  131. top left of the block is given as x,y and the bottom right is given
  132. as xx,yy.  The screen attributes for the block are changed to the
  133. paramter "attrib".
  134.  
  135. -------------------------------------------------------------------------
  136. CheckPrn
  137. -------------------------------------------------------------------------
  138. int CheckPrn( void );
  139.  
  140. Returns a 1 if the printer is attatched and ready to print.  Returns
  141. 0 if the printer is not attached, off-line, out of paper, etc.
  142.  
  143. -------------------------------------------------------------------------
  144. ClearBeg
  145. -------------------------------------------------------------------------
  146. char *ClearBeg( register char *cp );
  147.  
  148. Returns the address of the first non-space character in the string.
  149.  
  150. -------------------------------------------------------------------------
  151. ClearBuf
  152. -------------------------------------------------------------------------
  153. void ClearBuf( void );
  154.  
  155. Clears the keyboard buffer.
  156.  
  157. -------------------------------------------------------------------------
  158. ClearEnd
  159. -------------------------------------------------------------------------
  160. char *ClearEnd( register char *cp );
  161.  
  162. Deletes all spaces that appear at the end of a string.
  163.  
  164. -------------------------------------------------------------------------
  165. CopyFile
  166. -------------------------------------------------------------------------
  167. int CopyFile( char *src, char *dest );
  168.  
  169. Copies a disk file.
  170.  
  171. Returns -1 if there was not enough memory to allocate.
  172. Returns -2 if the source file was not found or not succesfully opened.
  173. Returns -3 if the destination file was not succesfully created.
  174. Returns -4 if there was an error writing to the destination file.
  175. Returns 0 if succesful.
  176.  
  177. -------------------------------------------------------------------------
  178. CurrentPos
  179. -------------------------------------------------------------------------
  180. unsigned char far *CurrentPos( void );
  181.  
  182. This is not a replacement for gotoxy.
  183.  
  184. Returns a far character pointer to the screen memory corresponding
  185. with the current cursor position.  Useful for writing your own fast
  186. video routines.  It automatically determines whether the display is
  187. monochrome or color, and returns the appropriate pointer.
  188.  
  189. -------------------------------------------------------------------------
  190. CursorOff
  191. -------------------------------------------------------------------------
  192. void CursorOff( void );
  193.  
  194. Turns the cursor off.
  195.  
  196. -------------------------------------------------------------------------
  197. CursorOn
  198. -------------------------------------------------------------------------
  199. void CursorOn( void );
  200.  
  201. Turns the cursor on.
  202.  
  203. -------------------------------------------------------------------------
  204. DrawBox
  205. -------------------------------------------------------------------------
  206. void DrawBox( int x, int y, int xx, int yy );
  207.  
  208. Draws a double line box on the screen.
  209.  
  210. -------------------------------------------------------------------------
  211. DrawBox1
  212. -------------------------------------------------------------------------
  213. void DrawBox1( int x, int y, int xx, int yy );
  214.  
  215. Draws a single line box on the screen.
  216.  
  217. -------------------------------------------------------------------------
  218. Exists
  219. -------------------------------------------------------------------------
  220. int Exists( char *filename );
  221.  
  222. Returns 1 if the file exists, 0 if not.
  223.  
  224. -------------------------------------------------------------------------
  225. ExplodeBox
  226. -------------------------------------------------------------------------
  227. void ExplodeBox( int x, int y, int xx, int yy );
  228.  
  229. Draws a double line box on the screen, exploding out from
  230. the center.
  231.  
  232. -------------------------------------------------------------------------
  233. ExplodeBox1
  234. -------------------------------------------------------------------------
  235. void ExplodeBox1( int x, int y, int xx, int yy );
  236.  
  237. Draws a single line box on the screen, exploding out from
  238. the center.
  239.  
  240. -------------------------------------------------------------------------
  241. FileName
  242. -------------------------------------------------------------------------
  243. char *FileName( FileStruc *fp );
  244.  
  245. Returns the filename from the structure fp.  If there is no
  246. extension, the period is not included.
  247.  
  248. -------------------------------------------------------------------------
  249. FileSize
  250. -------------------------------------------------------------------------
  251. long FileSize( char *filename );
  252.  
  253. Returns the size in bytes of the given file.  This differs from 
  254. the Turbo C funtion "filelength" in that you pass a filename
  255. rather than first openingthe file and then passing the handle.
  256.  
  257. -------------------------------------------------------------------------
  258. GComm
  259. -------------------------------------------------------------------------
  260. int GComm( void );
  261.  
  262. Returns the value of the next keypress.  The values for all special
  263. keys (F1, HOME, TAB, etc.) are defined in TCCLIB.H  If you include
  264. the header file TCCLIB.H, you may use the macros F1,F2,...F10,HOME,END,
  265. PGUP,PGDN,RIGHT,LEFT,UP,DOWN,TAB,etc.
  266.  
  267. -------------------------------------------------------------------------
  268. GetAllFields
  269. -------------------------------------------------------------------------
  270. void GetAllFields( FieldStruc *Field, int NUMFIELDS,
  271.                   int (*CharHandler)( int ch ),
  272.                   void (*Update)( void ) );
  273.  
  274. This function controls the input of multiple input fields on
  275. the screen until a negative value is passed back by the user
  276. function CharHandler.  The ESCape key does not automatically
  277. terminate the function, but rather is passed to CharHandler.
  278.  
  279. Parameters:
  280.     Field:     address of the array of structures
  281.     NUMFIELDS: how many structures are in the array
  282.     CharHandler: any keys not used by GetAllFields are passed to this
  283.                this allows you to handle the F1-F10 keys, etc. for
  284.                special functions of your own.
  285.                IMPORTANT: if this function returns a negative value,
  286.                GetAllFields will return to the calling funtion.
  287.     Update:    this function is called to update the screen between
  288.                the time the user finished one field and moves on to
  289.                another.  If you have calculations to perform based on
  290.                the value of certain fields and then want to show
  291.                the results, do it in this function.
  292.  
  293. Example:
  294. FieldStruc Example[] = {
  295.    10,  5, 15, F_PTR, Variable1, 1, 0,
  296.    20,  6, 15, F_PTR, Variable2, 0, 0,
  297.    30,  7, 15, F_PTR, Variable3, 1, 0,
  298.    40,  8, 15, F_PTR, Variable4, 1, 0,
  299.    50,  9, 15, F_PTR, Variable5, 1, 0,
  300.    60, 10, 15, F_PTR, Variable6, 1, 0,
  301. };
  302.  
  303. GetAllFields( &Example, 6 );
  304. /* this will get input from the user.  If the user presses any
  305.    cursor arrow key, the routine will determine which field to
  306.    goto next, then get that field next.  The second field has a
  307.    zero in the EditFlag position, which means that it will be
  308.    output, but cannot be edited or changed. */
  309.  
  310. -------------------------------------------------------------------------
  311. GetCursor
  312. -------------------------------------------------------------------------
  313. void GetCursor( int *Top, int *Bottom );
  314.  
  315. Returns the top and bottom lines of the current cursor.
  316. Be sure to pass the addresses of integers, rather than the
  317. integers themselves to this function.
  318.  
  319. Example: GetCursor( &topline, &bottomline );
  320.  
  321. -------------------------------------------------------------------------
  322. GetDouble
  323. -------------------------------------------------------------------------
  324. double GetDouble( void );
  325.  
  326. Accepts a string and returns the value of the string as a double.
  327.  
  328. -------------------------------------------------------------------------
  329. GetField
  330. -------------------------------------------------------------------------
  331. int GetField( FieldStruc *Field );
  332.  
  333. This is a powerful input function, capable of accepting text,
  334. integer, long, boolean, date, or double fields.
  335.  
  336. Before using this function, define a structure or array of 
  337. structures of type FieldStruc.
  338.  
  339. FieldStruc is defined in TCCLIB.H as having the following elements:
  340.     int   X             column where field starts
  341.     int   Y             row where field is
  342.     int   Len           length of field
  343.     int   Type          type of field (see chart below)
  344.     char *Address       address of variable being input
  345.     int   EditFlag      1 = allow input,  0 = view only
  346.     int   NumDecimals   how many digits to the right of the decimal
  347.                         for doubles.
  348.  
  349.      Types  Value  Description
  350.     ------  -----  ----------------
  351.     F_PTR     0    String (character array)
  352.     F_INT     1    integer
  353.     F_INT0    2    integer with preceding zeros
  354.     F_CHAR    3    single character
  355.     F_LNG     4    long
  356.     F_LNG0    5    long with preceding zeros
  357.     F_DBL     6    double
  358.     F_DATE    8    date
  359.     F_BLN     9    boolean (Y or N)
  360.  
  361. Return Values:
  362.     Pressing any of the following keys will return from GetField:
  363.  
  364.     SHFT_TAB   returns the value LEFT
  365.     CTL_RIGHT  returns the value LEFT
  366.  
  367.     TAB:       returns the value RIGHT
  368.     CTL_LEFT:  returns the value RIGHT
  369.  
  370.     The following keys return their own values:
  371.         CR  LF  DOWN  UP  PGDN  PGUP  
  372.         HOME  END  F1-F10  ESC
  373.  
  374.     RIGHT and LEFT return their respective values IF they 
  375.     are the first key pressed within a field.  Otherwise, 
  376.     they move the cursor back and forth within the field.
  377.  
  378. -------------------------------------------------------------------------
  379. GetFieldA
  380. -------------------------------------------------------------------------
  381. int GetFieldA( int x, int y, int len, int type, char *address );
  382.  
  383. This function can be used to accept a single entry field, and
  384. to relieve the programmer of setting up and array for just one
  385. entry.  See GetField for a list of Types.
  386.  
  387. -------------------------------------------------------------------------
  388. GetFile
  389. -------------------------------------------------------------------------
  390. char *GetFile( int x, int y, int xx, int yy,
  391.                char *Mask,
  392.                int FileAttrib,
  393.                int ExtOn );
  394.  
  395. This function draws a box and lists inside the box all files that
  396. match the pattern given.  The user may select a file from the list,
  397. or type in a filename at the keyboard.
  398.  
  399. -------------------------------------------------------------------------
  400. GetInt
  401. -------------------------------------------------------------------------
  402. int GetInt( void );
  403.  
  404. Accepts a string and returns the value of the string as a int.
  405.  
  406. -------------------------------------------------------------------------
  407. GetLine
  408. -------------------------------------------------------------------------
  409. int GetLine( char *ptr, int size, int start );
  410.  
  411. Accepts a line of input from the user.  The line cannot exceed
  412. "size" characters.  Entry will begin at position "start".  If the 
  413. user hits ESC, the routine will return 0.  Otherwise it returns
  414. the length of the string.
  415.  
  416. -------------------------------------------------------------------------
  417. GetLong
  418. -------------------------------------------------------------------------
  419. long GetLong( void );
  420.  
  421. Accepts a string and returns the value of the string as a long.
  422.  
  423. -------------------------------------------------------------------------
  424. GetRec
  425. -------------------------------------------------------------------------
  426. int GetRec( int filehandle, void *buffer, int sizeofrec, long fileptr );
  427.  
  428. This function reads "sizeofrec" bytes from position "fileptr"
  429. from the opened file into "buffer".  It returns 0 if successfull,
  430. -1 on error.
  431.  
  432. -------------------------------------------------------------------------
  433. GetScreen
  434. -------------------------------------------------------------------------
  435. void GetScreen( char *buffer );
  436.  
  437. Stores the 4000 bytes of screen memory at the buffer.  Make sure
  438. that the buffer is 4000 or more bytes long.
  439.  
  440. -------------------------------------------------------------------------
  441. GetVidMode
  442. -------------------------------------------------------------------------
  443. int GetVidMode( void );
  444.  
  445. Returns the current video mode.
  446.  
  447. -------------------------------------------------------------------------
  448. HideCursor
  449. -------------------------------------------------------------------------
  450. void HideCursor( void );
  451.  
  452. This function hides the cursor just off the screen, rather than
  453. turning it off.  The next video output function will restore the
  454. cursor to the screen.  Exceptions to this are the AtSay functions
  455. and OutChar functions which write directly to screen memory and
  456. do not update the cursor position.
  457.  
  458. -------------------------------------------------------------------------
  459. HLin
  460. -------------------------------------------------------------------------
  461. void HLin( int x, int y, int xx, int yy );
  462.  
  463. Draws a horizontal double line on the screen.
  464.  
  465. -------------------------------------------------------------------------
  466. HLin1
  467. -------------------------------------------------------------------------
  468. void HLin1( int x, int y, int xx, int yy );
  469.  
  470. Draws a horizontal single line on the screen.
  471.  
  472. -------------------------------------------------------------------------
  473. IsAT
  474. -------------------------------------------------------------------------
  475. int IsAT( void );
  476.  
  477. Returns a 1 if the machine is an AT-class.
  478.  
  479. -------------------------------------------------------------------------
  480. IsCGA
  481. -------------------------------------------------------------------------
  482. int IsCGA( void );
  483.  
  484. Returns a 1 if the current video is to a CGA monitor.
  485.  
  486. -------------------------------------------------------------------------
  487. IsEGA
  488. -------------------------------------------------------------------------
  489. int IsEGA( void );
  490.  
  491. Returns a 1 if the current video is to a EGA monitor.
  492.  
  493. -------------------------------------------------------------------------
  494. IsMONO
  495. -------------------------------------------------------------------------
  496. int IsMONO( void );
  497.  
  498. Returns a 1 if the current video is to a monochrome monitor.
  499.  
  500. -------------------------------------------------------------------------
  501. MaxRAM
  502. -------------------------------------------------------------------------
  503. long MaxRAM( void );
  504.  
  505. Returns the number of bytes of installed RAM.
  506.  
  507. -------------------------------------------------------------------------
  508. NormalText
  509. -------------------------------------------------------------------------
  510. void NormalText( void );
  511.  
  512. Changes the text attribute to the global variable A_NORMAL.
  513.  
  514. -------------------------------------------------------------------------
  515. NPrint
  516. -------------------------------------------------------------------------
  517. void NPrint( int num, char *cp );
  518.  
  519. Prints the first "num" characters of cp.
  520.  
  521. -------------------------------------------------------------------------
  522. NPrintA
  523. -------------------------------------------------------------------------
  524. void NPrintA( int num, int attrib, char *cp );
  525.  
  526. Prints the first "num" characters of cp, using "attrib" as the 
  527. text attribute.
  528.  
  529. -------------------------------------------------------------------------
  530. NPrintF
  531. -------------------------------------------------------------------------
  532. void NPrintF( int num, char *fmt, ... );
  533.  
  534. Prints the first "num" characters of the expanded paramter.
  535.  
  536. -------------------------------------------------------------------------
  537. NPrintFA
  538. -------------------------------------------------------------------------
  539. void NPrintFA( int num, int attrib, char *fmt, ... );
  540.  
  541. Prints the first "num" characters of the expanded paramter, 
  542. using "attrib" for the text attribute.
  543.  
  544. -------------------------------------------------------------------------
  545. NumLock
  546. -------------------------------------------------------------------------
  547. void NumLock( int flag );
  548.  
  549. If "flag" is non-zero, the num lock will be turned on.  If "flag"
  550. is zero, the num lock will be turned off.
  551.  
  552. -------------------------------------------------------------------------
  553. OutChar
  554. -------------------------------------------------------------------------
  555. void OutChar( unsigned char c );
  556.  
  557. Outputs the character at the current row and column.
  558.  
  559. -------------------------------------------------------------------------
  560. OutCharA
  561. -------------------------------------------------------------------------
  562. void OutCharA( unsigned char attrib, unsigned char c );
  563.  
  564. Outputs the character at the current row and column, using
  565. "attrib" for the text attribute.
  566.  
  567. -------------------------------------------------------------------------
  568. PopCurpos
  569. -------------------------------------------------------------------------
  570. void PushVurpos( void );
  571.  
  572. Restores the cursor position to what it was when PushCurpos was called.
  573.  
  574. -------------------------------------------------------------------------
  575. PushCurpos
  576. -------------------------------------------------------------------------
  577. void PushVurpos( void );
  578.  
  579. Saves the current cursor position, to be reset by PopCurpos
  580.  
  581. -------------------------------------------------------------------------
  582. PutCursor
  583. -------------------------------------------------------------------------
  584. void PutCursor( int Top, int Bottom );
  585.  
  586. This is not a replacement for gotoxy.  Rather, it determines
  587. how big the cursor is.  Use this to create a block cursor, or
  588. one that is a dash rather than an underline.
  589.  
  590. -------------------------------------------------------------------------
  591. PutDate
  592. -------------------------------------------------------------------------
  593. void PutDate( int x, int y, int format );
  594.  
  595. Puts the current date on the screen at the given position.
  596.  
  597.     Format  Output
  598.     ------  ----------------
  599.        1    MM/DD/YY
  600.        2    MMM DD, YYYY
  601.        3    DD-MMM-YY
  602.        4    MMM YY
  603.  
  604. -------------------------------------------------------------------------
  605. PutField
  606. -------------------------------------------------------------------------
  607. void PutField( FieldStruc *Field );
  608.  
  609. Puts the given field on the screen.  See Getfield for a description
  610. of FieldStruc.
  611.  
  612. -------------------------------------------------------------------------
  613. PutRec
  614. -------------------------------------------------------------------------
  615. int PutRec( int filehandle, void *buffer, int sizeofrec, long fileptr );
  616.  
  617. Writes from "buffer" to the file.  Returns 0 on success, -1 on error.
  618. See also GetRec.
  619.  
  620. -------------------------------------------------------------------------
  621. PutScreen
  622. -------------------------------------------------------------------------
  623. void PutScreen( char *buffer );
  624.  
  625. Puts from memory to the screen.  Buffer must be 4000 bytes long.
  626.  
  627. -------------------------------------------------------------------------
  628. PutTime
  629. -------------------------------------------------------------------------
  630. void PutTime( int x, int y, int format );
  631.  
  632. Puts the current time on the screen at the given position.
  633.  
  634.     Format  Output
  635.     ------  ----------------
  636.        1    HH:MM:SS (24-hour)
  637.        2    HH:MM    (24-hour)
  638.        3    HH:MM:SS AM/PM
  639.        4    HH:MM    AM/PM
  640.  
  641. -------------------------------------------------------------------------
  642. RepChar
  643. -------------------------------------------------------------------------
  644. void RepChar( int num, unsigned char c );
  645.  
  646. Writes the character "c" "num" times at the given location.
  647.  
  648. -------------------------------------------------------------------------
  649. RepCharAttr
  650. -------------------------------------------------------------------------
  651. void RepCharAttr( int num, unsigned char attrib, unsigned char c );
  652.  
  653. Writes the character "c" "num" times at the given location,
  654. using "attrib" for the text attribute.
  655.  
  656. -------------------------------------------------------------------------
  657. RestoreCurPos
  658. -------------------------------------------------------------------------
  659. void RestoreCurPos( unsigned char far *scptr );
  660.  
  661. This funtion is called at the end of the Say family of functions
  662. to set the cursor position after printing the string.  It can be 
  663. used to set the cursor position to an absolute screen memory 
  664. position.
  665.  
  666. -------------------------------------------------------------------------
  667. ReverseText
  668. -------------------------------------------------------------------------
  669. void ReverseText( void );
  670.  
  671. Changes the text attribute to the global variable A_REVERSE.
  672.  
  673. -------------------------------------------------------------------------
  674. Say
  675. -------------------------------------------------------------------------
  676. void Say( register char *cp );
  677.  
  678. Same as puts or cputs, only quicker.
  679.  
  680. -------------------------------------------------------------------------
  681. SayA
  682. -------------------------------------------------------------------------
  683. void SayA( unsigned char attrib, register char *cp );
  684.  
  685. Same as Say, except that "attrib" is used for text attributes.
  686.  
  687. -------------------------------------------------------------------------
  688. SayF
  689. -------------------------------------------------------------------------
  690. void SayF( char *fmt, ... );
  691.  
  692. Same as printf or cprintf, only quicker.
  693.  
  694. -------------------------------------------------------------------------
  695. SayFA
  696. -------------------------------------------------------------------------
  697. void SayFA( char attrib, char *fmt, ... );
  698.  
  699. Same as printf or cprintf.  "attrib" is used for text attributes.
  700.  
  701. -------------------------------------------------------------------------
  702. ScanDir
  703. -------------------------------------------------------------------------
  704. FileStruc *ScanDir( char *Mask, int FileAttrib );
  705.  
  706. Searches for files matching the mask.  If no directory
  707. is included in the mask, the current  directory will be used.
  708. "FileAttrib" tells ScanDir which types of files to allow.
  709. (Hidden, System, etc.)  0xff includes files of all types, 
  710. 0x00 includes only those files which appear in a normal directory 
  711. listing from DOS. See DOS.H for file types and corresponding 
  712. attributes.
  713.  
  714. -------------------------------------------------------------------------
  715. ScanTree
  716. -------------------------------------------------------------------------
  717. void ScanTree( char *path, char *filespec,
  718.                void (*FN)(FileStruc *f, char *p) );
  719.  
  720. ScanTree searches through "path" for files matching "filespec".
  721. It also searches any subdirectories found while searching "path".
  722. Once it finds a matching file, it calls the user-written function 
  723. "FN", passing pointers to the FileStruc for the file and the Path 
  724. where the file was found.
  725.  
  726. EXAMPLE:  Whereis Program to search drive C.  It will print
  727.           the path and filename of every file on drive C that
  728.           matches the command line argument that is passed to
  729.           this program.  You can easily extend this to include
  730.           size, date and time of the file; even stop after each
  731.           page full to wait for a keystroke.
  732.  
  733. #include "tcclib.h"
  734.  
  735. void PrintName( FileStruc *f, char *p )
  736. {
  737.     SayF("%s%s\n", p, FileName( f ) );  /* see FileName */
  738. /*
  739.     (Returning a -1 here will stop ScanTree dead in it's tracks.
  740.     see the Demo program for an example of this.)
  741. */
  742.     return( 0 );
  743. }
  744.  
  745. main( int argc, char *argv[] )
  746. {
  747.     ScanTree( "C:\\", argv[1], PrintName );
  748. }
  749.  
  750. -------------------------------------------------------------------------
  751. ScrAttr
  752. -------------------------------------------------------------------------
  753. int ScrAttr( void );
  754.  
  755. Returns the text attribute at the current location of the cursor.
  756.  
  757. -------------------------------------------------------------------------
  758. ScrChar
  759. -------------------------------------------------------------------------
  760. int ScrChar( void );
  761.  
  762. Returns the text character at the current location of the cursor.
  763.  
  764. -------------------------------------------------------------------------
  765. ScrollDown
  766. -------------------------------------------------------------------------
  767. void ScrollDown( int x, int y, int xx, int yy, int n );
  768.  
  769. Scrolls the given section of the screen down "n" lines.  If "n"
  770. equals 0, the section of the screen is blanked.
  771.  
  772. -------------------------------------------------------------------------
  773. ScrollLock
  774. -------------------------------------------------------------------------
  775. void ScrollLock( int flag );
  776.  
  777. If "flag" is non-zero, the scroll lock will be turned on.  If "flag"
  778. is zero, the scroll lock will be turned off.
  779.  
  780. -------------------------------------------------------------------------
  781. ScrollUp
  782. -------------------------------------------------------------------------
  783. void ScrollUp( int x, int y, int xx, int yy, int n );
  784.  
  785. Scrolls the given section of the screen up "n" lines.  If "n"
  786. equals 0, the section of the screen is blanked.
  787.  
  788. -------------------------------------------------------------------------
  789. ScrPtr
  790. -------------------------------------------------------------------------
  791. unsigned char far *ScrPtr( int col, int row );
  792.  
  793. Returns a pointer into screen memory for the given row and column.
  794.  
  795. -------------------------------------------------------------------------
  796. SetAttrib
  797. -------------------------------------------------------------------------
  798. void SetAttrib( char attribute  );
  799.  
  800. Set the text attribute to "attribute"
  801.  
  802. -------------------------------------------------------------------------
  803. SetVidMode
  804. -------------------------------------------------------------------------
  805. void SetVidMode( int mode );
  806.  
  807. Set the video mode to "mode"
  808.  
  809. -------------------------------------------------------------------------
  810. StrLeft
  811. -------------------------------------------------------------------------
  812. void StrLeft( char *dest, char *src, int num );
  813.  
  814. Copies the leftmost "num" characters from "src" to "dest".
  815.  
  816. -------------------------------------------------------------------------
  817. StrRight
  818. -------------------------------------------------------------------------
  819. void StrRight( char *dest, char *src, int num );
  820.  
  821. Copies the rightmost "num" characters from "src" to "dest".
  822.  
  823. -------------------------------------------------------------------------
  824. StrRpl
  825. -------------------------------------------------------------------------
  826. void StrRpl( char *string, int startpos, int num, char *replacestring );
  827.  
  828. Replaces a portion of "string" with "replacestring".  It begins
  829. replacing at position "startpos", and replaces "num" characters.
  830.  
  831. -------------------------------------------------------------------------
  832. TimeElapsed
  833. -------------------------------------------------------------------------
  834. double TimeElapsed( void );
  835.  
  836. Returns how many seconds have passed since "TimerStart" was
  837. last called.
  838.  
  839. -------------------------------------------------------------------------
  840. TimerStart
  841. -------------------------------------------------------------------------
  842. void TimerStart( void );
  843.  
  844. Begins the timer.
  845.  
  846. -------------------------------------------------------------------------
  847. VLin
  848. -------------------------------------------------------------------------
  849. void VLin( int x, int y, int xx, int yy );
  850.  
  851. Draws a vertical double line on the screen.
  852.  
  853. -------------------------------------------------------------------------
  854. VLin1
  855. -------------------------------------------------------------------------
  856. void VLin1( int x, int y, int xx, int yy );
  857.  
  858. Draws a single vertical line on the screen.
  859.  
  860. -------------------------------------------------------------------------
  861. WindowLister
  862. -------------------------------------------------------------------------
  863. int WindowLister( int x, int y, int xx, int yy,
  864.                          int CharToQuitOn,
  865.                          int *NumItems,
  866.                          int NumToStartWith,
  867.                          int(*CharHandler)(int ch, int ndx, int line),
  868.                          void(*ScreenClearer)( void ),
  869.                          void(*DisplayLineFunction)(int Index) );
  870.  
  871. This function may be difficult to understand, but will be
  872. well worth the time.  It lets you browse through an array of 
  873. structures or simple data types, using the PgDn/PgUp and up/down
  874. arrows.  You must first create three special functions.  This function
  875. should save you lots of programming time, once you learn how to
  876. use it.  It returns the index of the item it was highlighting when the
  877. "CharToQuitOn" key was pressed.
  878.  
  879. Parameters:
  880.     x, y, xx, yy:        the section of the screen for WindowLister
  881.                          to use.
  882.  
  883.     CharToQuitOn:        this will usually be ESC.
  884.  
  885.     NumItems:            this tells WindowLister how many records are 
  886.                          in the array.  It is passed as the address
  887.                          of an integer so that if during operation
  888.                          you delete or add records, you just change 
  889.                          the value of this integer, and WindowLister
  890.                          will adjust accordingly.
  891.  
  892.     NumToStartWith:      which record to begin with.  Usually 0.
  893.  
  894.     CharHandler:         whenever WindowLister receives a key it
  895.                          doesn't process, it will pass the inkey
  896.                          to your CharHandler function.  Your character
  897.                          handler function should perform whatever is
  898.                          appropriate for the given keypress,
  899.                          then it should return the index into
  900.                          the array that should be highlighted next.
  901.                          This will usually be the same "ndx" that was
  902.                          passed to it, but you can change it and 
  903.                          WindowLister will jump to the new index you
  904.                          pass back to it.
  905.  
  906.     ScreenClearer:       This clears whatever sections of the screen
  907.                          are filled with the records of the array.
  908.  
  909.     DisplayLineFunction: This function should output a single record of 
  910.                          the array.
  911.  
  912. Example:
  913. #define MAIN
  914. #include "tcclib.h"
  915.  
  916. typedef struct {
  917.     char Name[21];
  918.     char City[21];
  919.     char State[3];
  920.     long ZIP;
  921. } ExampleType;
  922.  
  923. ExampleType Example[100];
  924.  
  925. int MaxItems = 50; /* we will assume that 50 are filled with data.
  926.                       NOTE: this number represent how many are currently 
  927.                       in use, not the total capacity which is 100. */
  928.  
  929. int ElementCompare( ExampleType *a, ExampleType *b )
  930. /* this is defined for the quicksort below */
  931. {
  932.     return( stricmp( a->Name, b->Name ) );
  933. }
  934.  
  935. int ExampleCharacterHandler( int ch, int ndx, int line )
  936. /* ch   = the character WindowLister didn't recognize F1-F10, INS, DEL, 
  937.           etc. */
  938. /* ndx  = index into the array where the WindowLister is */
  939. /* line = which line of those displayed is currently highlighted; i.e.
  940.           if 20 lines of the 50 are shown on the screen at once, and
  941.           line 10 is currently highlighted, this will be 10.  
  942.           Subtracting this from the ndx paramter will give the index to
  943.           the record at the top of the window.
  944. */
  945. {
  946.     switch( ch ) {
  947.         case DEL:    /*  Delete a record */
  948.             /* perform deletion of "ndx"th record of array Example.
  949.                the code is not written here */
  950.             MaxItems--;
  951.             break;
  952.         case INS:
  953.             /* perform an insert here - record at position "ndx" 
  954.                the code is not written here */
  955.             MaxItems++;
  956.             break;
  957.         case F4: 
  958.             /* sort the items in the array Example */
  959.             qsort( &Example, MaxItems, sizeof( ExampleType ), 
  960.                 ElementCompare );
  961.             break;
  962.     }
  963.     return( ndx );
  964. }
  965.  
  966. void ExampleScreenClearer( void )
  967. /* usually this will be a BlockErase, but if you want to get fancy,
  968.    you have the flexibilty to do just about anything you want to */
  969. {
  970.     BlockErase( 6, 6, 74, 19 );
  971. }
  972.  
  973. void ExampleDisplayFunction( int Index )
  974. /* All that this function needs to do is output a single record
  975.    in the proper format.  WindowLister will position the cursor before
  976.    calling this routine, so this should not reposition the cursor
  977.    before printing. Also, no newline is needed at the end. */
  978. {
  979.     SayF("%-20s  %-20s  %-2s  %05ld", 
  980.         Example[Index].Name,
  981.         Example[Index].City,
  982.         Example[Index].State,
  983.         Example[Index].ZIP );
  984. }
  985.  
  986. main()
  987. {
  988.     clrscr();
  989.     DrawBox( 4, 4, 76, 21 );
  990.     Center( 25, "Use INS, DEL;  F4=Sort" );
  991.     WindowLister( 5, 5, 75, 20, ESC, &MaxItems, 0, 
  992.                   ExampleCharacterHandler,
  993.                   ExampleScreenClearer,
  994.                   ExampleDisplayFunction );
  995. }
  996.  
  997.